Common Nginx Commands: Essential Start, Stop, Restart, and Configuration Check for Beginners
This article introduces the core commands for Nginx daily management to help beginners get started quickly. There are two ways to start Nginx: using `nginx` for source code installation, and `sudo systemctl start nginx` for system services installed via yum/apt. Verification can be done by `ps aux | grep nginx` or accessing the test page. For stopping, there are quick stop (`nginx -s stop`, which may interrupt ongoing requests) and graceful stop (`nginx -s quit`, recommended, waiting for current requests to complete). The difference lies in whether the service is interrupted. For restarting, there are two methods: reloading the configuration (`nginx -s reload`, essential after configuration changes without interruption) and full restart (`systemctl restart`, which may cause brief interruption). Configuration checks require first verifying syntax with `nginx -t`, then applying changes with `nginx -s reload`. `nginx -T` can display the complete configuration. Common commands for beginners include start/stop, reload, and syntax checking. Note permissions, configuration paths, and log troubleshooting. Mastering these commands enables efficient daily Nginx operation and maintenance.
Read MoreNginx Beginner's Guide: Configuring an Accessible Web Server
### A Beginner's Guide to Nginx Nginx is a high-performance, lightweight web server/reverse proxy, ideal for high-concurrency scenarios. It features low resource consumption, flexible configuration, and ease of use. **Installation**: On mainstream Linux systems (Ubuntu/Debian/CentOS/RHEL), install via `apt` or `dnf`. Start and enable Nginx with `systemctl start/ enable nginx`, then verify with `systemctl status nginx` or by accessing the server's IP address. **Core Configuration**: Configuration files are located in `/etc/nginx/`, where `nginx.conf` is the main configuration file and `conf.d/` stores virtual host configurations. Create a website directory (e.g., `/var/www/html`), write an `index.html` file, and add a `server` block in `conf.d/` (specifying port 80 listening and the website directory). **Testing & Management**: After modifying configurations, use `nginx -t` to check syntax and `systemctl reload` to apply changes. Ensure port 80 is open (firewall settings) and file permissions are correct for testing access. Common commands include `start/stop/restart/reload nginx` and status checks. **Summary**
Read More